package com.lcy.mapper;

import com.mybatisflex.core.BaseMapper;
import com.lcy.model.entity.AiCodeAnalysis;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Optional;

public interface AiCodeAnalysisMapper extends BaseMapper<AiCodeAnalysis> {
    
//    @Select("SELECT * FROM ai_code_analysis WHERE problem_submit_id = #{problemSubmitId}")
//    Optional<AiCodeAnalysis> findByProblemSubmitId(@Param("problemSubmitId") Long problemSubmitId);
@Insert("INSERT INTO ai_code_analysis(problem_submit_id, analysis_result, created_at) " +
        "VALUES (#{problemSubmitId}, #{analysisResult}, NOW())")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insertAnalysis(AiCodeAnalysis analysis);

    @Select("SELECT * FROM ai_code_analysis WHERE problem_submit_id = #{problemSubmitId}")
    Optional<AiCodeAnalysis> findByProblemSubmitId(@Param("problemSubmitId") Long problemSubmitId);
}

